package com.sentinel.demo03.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.sentinel.demo03.handler.MyBlockHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class HelloService {
    @SentinelResource(
            value = "sayHiService",
            blockHandler = "sayHiDegrade",
            blockHandlerClass = MyBlockHandler.class
    )
    public String sayHi(String name) {
        //睡眠100ms，测试熔断
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "Hello ["+name+"], I'm sentinel.";
    }
}
